package handConsistentHash;

/**
 * @author 03010570
 * @date 2020/07/08
 * describe:    Virtual 虚拟节点
 * 属性：
 * 1、 物理节点 Physical
 * 2、 虚拟节点的下标 replicasIndex
 * <p>
 * 方法；
 * 1、 toString
 * 2、 matches 根据 ip 查找匹配 物理节点
 */
public class VNode {

    private PNode pNode;
    private Integer replicasIndex;

    public VNode(PNode pNode, Integer replicasIndex) {
        this.pNode = pNode;
        this.replicasIndex = replicasIndex;
    }

    public VNode() {
    }

    public boolean matches(String name) {
        return pNode.toString().equalsIgnoreCase(name);
    }

    @Override
    public String toString() {
        return pNode.toString() + ":" + replicasIndex;
    }

    public PNode getpNode() {
        return pNode;
    }

    public void setpNode(PNode pNode) {
        this.pNode = pNode;
    }

    public Integer getReplicasIndex() {
        return replicasIndex;
    }

    public void setReplicasIndex(Integer replicasIndex) {
        this.replicasIndex = replicasIndex;
    }
}
